{layout name="public/layout" /}

		{include file='yxnavbar'}

<link rel="stylesheet" href="{$_G['URL']['APP_CSS']}back.css">
	<style type="text/css">
	.order-detail-info>div{margin-bottom:10px; padding-left:15px;}
	.page-trade-order h4{font-size:14px; font-weight:700;}
	.page-trade-order .form-group{margin-bottom:0;}
	.page-trade-order .form-group .control-label{font-weight:normal; color:#999;}
	.page-trade-order .order-infos{border-right:1px solid #ddd;}
	.page-trade-order .parting-line{height:1px;border-top:1px dashed #e5e5e5; margin:3px 0;}
	.page-trade-order .order-state{padding-left:40px; position:relative; margin:20px 0 40px;}
	.page-trade-order .order-state>span{color:#07d; position:absolute; left:0; top:5px; font-size:25px; display:inline-block; width:30px; height:30px; border:1px solid #07d; border-radius:30px; text-align:center; line-height:30px;}
	#close-order ul li{padding:5px 15px; cursor:pointer;}
	#close-order ul li:hover{background:#eee;}
	.fix a.js-order-edit-address{display:none; color:red;}
	.fix:hover a.js-order-edit-address{display:inline;}
	.page-trade-order .col-sm-9{word-break: break-word; overflow:hidden;}
	.table-log>tbody>tr>td{border-top:none;}
</style>
{if $op == 'display'}
<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">筛选 共{$total}条</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="paystate" value="{$paystate}" />
				<input type="hidden" name="themeid" value="{$themeid}" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
					<div class="col-sm-9 col-xs-9 col-md-9">
						<input class="form-control" name="keyword" placeholder="输入用户名或手机号" type="text" value="{$_P['keyword']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">按礼品</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						 <select class="form-control" name="gid">
                        <option value="" >全部</option>
                   		{loop $friendlipinlist $row}
			         		<option value="{$row['id']}" {if $gid == $row['id'] }selected="selected"{/if}>{$row['giftname']}</option>
			       		{/loop}
			     		 </select>
					</div>
				</div>
				<div class="form-group clearfix">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">浏览时间</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						{php echo view_form_field_daterange('createtime', array('starttime' => date('Y-m-d', $starttime), 'endtime' => date('Y-m-d', $endtime),));}
						
					</div>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
					</div>
				</div>
			</form>
		</div>
	</div>
		<ul class="order-nav order-nav-tabs">
			<li {if $status == -1}class="active"{/if}><a href="{php echo filter_url('status:-1');}">所有记录</a></li>
			<!-- <li {if $status == 0}class="active"{/if}><a href="{php echo filter_url('status:0');}">未核销定单</a></li>
			<li {if $status == 1}class="active"{/if}><a href="{php echo filter_url('status:1');}">已核销定单</a></li> -->
		</ul>
		<div class="panel panel-default">
			<div class="panel-body table-responsive" style="overflow:inherit">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th width="50">ID</th>
							<th>微信头像</th>
							<th>微信昵称</th>
							<th>姓名</th>
							<th>电话</th>
							<th>礼品</th>
							<th>消费点数</th>
							<th>时间</th>
							<th style="width:150px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
							<td><b>{$row['id']}</b></td>
							<td>
								<img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;">
							</td>
							<td>
								{$row['nickname']}
							</td>
							<td>
								{$row['username']}
							</td>
							<td>
								{$row['mobile']}
							</td>
							<td>
								
									<a href="{php echo createWebUrl($do, array('op' => 'display','themeid'=>$themeid, 'gid' => $row['giftid']));}"  title="查看该礼品兑换记录" data-toggle="tooltip" data-placement="top">{$row['giftname']}</a>
							</td>
							<td>
								{$row['duihuan']}
							</td>

							<td>{php echo date('Y-m-d H:i:s', $row['addtime']);}</td>
							<td style="text-align:right; overflow:visible;">
								<div class="btn-group">
									<a href="{php echo createWebUrl($do, array('op' => 'delete','themeid'=>$themeid, 'id' => $row['id'],'uid' => $row['uid'], 'giftid' => $row['giftid'],'duihuan'=>$row['duihuan']));}" class="btn btn-danger btn-sm" onclick="if(!confirm('记录相关的数据将全被删除,不可恢复，确定删除吗')) return false;"  title="删除" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
								</div>
							</td>
						</tr>
						{/loop}
					
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
</div>
<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		require(['underscore', 'bootstrap.switch'], function() {
			$(":checkbox[name='isluck[]']").bootstrapSwitch();
			$(":checkbox[name='isluck[]']").on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var isluck = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl('record', array('op' => 'isluck','themeid'=>$themeid));}", {isluck:isluck,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(":checkbox[name='status[]']").on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 2 : 1;
				$.post("{php echo createWebUrl('record', array('op' => 'status','themeid'=>$themeid));}", {status:status,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
			
			
			
			
		});
	});
</script>
<script type="text/javascript">
require(['util'], function(u){

	$('#selectall').click(function(){
		$('#form-order :checkbox').prop('checked', $(this).prop('checked'));
	});

	$('.btn-order').click(function(){
		if($('#form-order :checkbox:checked').length == 0) {
			u.message('请选择定单', '', 'error');
			return false;
		}
		if(!confirm('确定修改定单的状态吗')) {
			return false;
		}
		$('#form-order #status').val($(this).data('id'));
		$('#form-order #type').val($(this).data('type'));
		$('#form-order').submit();
		return false;
	});

	$('.btn-cancel').click(function(e){
		var pay = $(this).data('pay');
		var pay_type = $(this).data('pay-type');
		var tip = '确定取消定单吗';
		if(pay == 1) {
			if(pay_type == 'cash') {
				var tip = '该定单为现金支付, 取消定单需要商家自己处理退款, 确定取消定单吗';
			} else if(pay_type != 'delivery') {
				var tip = '该定单为线上支付, 取消定单将发起退款流程, 确定取消定单吗';
			}
		}
		if(!confirm(tip)) {
			e.preventDefault();
		}
		return true;
	});


});
</script>
{elseif $op == 'show'}
<form class="form-horizontal" role="form">
	<div class="page-trade-order">
		<div class="order-list">
			<div class="freight-content">
				<div class="freight-template-item panel panel-default">
					<div class="panel-body clearfix">
						<div class="col-xs-12 col-sm-6 order-infos">
							<h4>定单信息</h4>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单编号：</label>
								<div class="col-md-9 form-control-static">
									{$order['ordersn']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">所属类型：</label>
								<div class="col-md-9 form-control-static">
									{if $order['ordertype']=='special'}
									<span class="label label-info">专题</span>
							{elseif $order['ordertype']=='activity'}
									<span class="label label-primary">活动</span>
							{elseif $order['ordertype']=='buy'}
									<span class="label label-primary">商品</span>
							{elseif $order['ordertype']=='scanpay'}
									<span class="label label-primary">扫码支付</span>
									{else}
									<span class="label label-warning">其他</span>
									{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">客户信息：</label>
								<div class="col-md-9 form-control-static">
									{$order['username']} {$order['mobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">下单时间：</label>
								<div class="col-md-9 form-control-static">
									{php echo date('Y-m-d H:i:s', $order['addtime']);}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单状态：</label>
								<div class="col-md-9 form-control-static">
									{if $order['status']=='0'}
									<span class="label label-warning">未支付</span>
								{elseif $order['status']=='1'}
									<span class="label label-success">未核销</span>
								{elseif $order['status']=='2'}
									<span class="label label-primary">已核销</span>
								{else}
									<span class="label label-warning">其他</span>
								{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单价格：</label>
								<div class="col-md-9 form-control-static">
									￥ {$order['orderfee']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">实际支付：</label>
								<div class="col-md-9 form-control-static">
									￥ {$order['realfee']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">卡券使用：</label>
								<div class="col-md-9 form-control-static">
									{if $row['usecard']==0}
							<span class="label label-info">未使用</span>
							{else}
							<span class="label label-primary">已使用</span>
							{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">付款方式：</label>
								<div class="col-md-9 form-control-static">
									{if !$order['paystate']}
										<span class="label label-danger">未支付</span>
									{else}
										{if $order['type']=='credit'}
											<span class="label label-info">余额支付</span>
											{elseif $order['type']=='wechat'}
											<span class="label label-success">微信支付</span>
											{elseif $order['type']=='delivery'}
											<span class="label label-primary">货到付款</span>
											{else}
											<span class="label label-warning">其他方式</span>
											{/if}
									{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">付款时间：</label>
								<div class="col-md-9 form-control-static">
									{php echo date('Y-m-d H:i:s', $order['paytime']);}
								</div>
							</div>
							
							
						</div>
{if $order['ordertype']=='special'}
						<div class="col-xs-12 col-sm-6">
							<h4>所属专题</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">专题名称：</label>
								<div class="col-md-9 form-control-static">
									{$goods['special']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">购买商品：</label>
								<div class="col-md-9 form-control-static">
									{$goods['title']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品数量：</label>
								<div class="col-md-9 form-control-static">
									{$goods['count']}
								</div>
							</div>
														<div class="form-group clearfix">
								<label class="col-md-3 control-label">收货人：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzusername']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">电话：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzmobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">地址：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzaddress']}
								</div>
							</div>
						</div>
{elseif $order['ordertype']=='activity'}
						<div class="col-xs-12 col-sm-6">
							<h4>所属活动</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">活动名称：</label>
								<div class="col-md-9 form-control-static">
									{$activity['title']}
								</div>
							</div>
							{loop $liaisons $item}
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">报名人信息：</label>
								<div class="col-md-9 form-control-static">
									{$item['username']} {$item['mobile']} 
								</div>
							</div>
							
							{/loop}
						</div>
{elseif $order['ordertype']=='buy'}
						<div class="col-xs-12 col-sm-6">
							<h4>商品信息</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品名称：</label>
								<div class="col-md-9 form-control-static">
									{$goods['title']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品数量：</label>
								<div class="col-md-9 form-control-static">
									{$goods['count']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">收货人：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzusername']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">电话：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzmobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">地址：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzaddress']}
								</div>
							</div>
						</div>
{elseif $order['ordertype']=='scanpay'}
						<div class="col-xs-12 col-sm-6">
							<h4>商户信息</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商户名称：</label>
								<div class="col-md-9 form-control-static">
									{$shop['title']}
								</div>
							</div>
						</div>
{else}
其他
{/if}

						
						
						
						
					</div>
				</div>
			</div>
		</div>
	</div>

</form>
{/if}
